<template>
    <div class="newsinfo-container">
        <div class="title">{{newsInfo.title}}</div>
        <p class="subtitle">
            <span>发布时间:{{newsInfo.add_time|dateFormat}}</span>
            <span>点击次数:{{newsInfo.click}}</span>
        </p>
        <hr>
        <div class="info" v-html="newsInfo.content">
           
        </div>
        <hr>
        <PingLun :id="this.id"></PingLun>
    </div>
</template>
<script>
import PingLun from "../subcomponents/PingLun.vue";
export default {
    data(){
        return{
            id:this.$route.params.id,
            newsInfo:{}
        }
    },
    components:{
        PingLun
    },
    created(){
       this.getNewsInfo();
    },
    methods:{
        getNewsInfo(){
            this.$http.get("api/getnew/"+this.id).then((resolve)=>{
                if(resolve.body.status===0){
                    this.newsInfo = resolve.body.message[0];
                }else{
                    alert("请求失败")
                }
            })
        }
    }
}
</script>
<style>
   .newsinfo-container{
       padding:0 10px;
   }
   .newsinfo-container .title{
       font-size:16px;
       color:red;
       text-align:center;
       margin:8px 0;
   }
   .newsinfo-container .subtitle{
       display:flex;
       justify-content:space-between;
       color:#226aff;
   }
</style>

